%%%-------------------------------------------------------------------
%%% File    : b2bua_supervisor.erl
%%% Author  : Anil Kumar S. R. <sranil@gmail.com>
%%% Description : 
%%%
%%% Created : 26 Aug 2010 by Anil Kumar S. R. <sranil@gmail.com>
%%%-------------------------------------------------------------------
-module(b2bua_supervisor).

-behaviour(supervisor).

%% API
-export([start_link/0]).

%% Supervisor callbacks
-export([init/1]).

%%====================================================================
%% API functions
%%====================================================================
%%--------------------------------------------------------------------
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
%% Description: Starts the supervisor
%%--------------------------------------------------------------------
start_link() ->
	supervisor:start_link(?MODULE, []).

%%====================================================================
%% Supervisor callbacks
%%====================================================================
%%--------------------------------------------------------------------
%% Func: init(Args) -> {ok,  {SupFlags,  [ChildSpec]}} |
%%                     ignore                          |
%%                     {error, Reason}
%% Description: Whenever a supervisor is started using 
%% supervisor:start_link/[2,3], this function is called by the new process 
%% to find out about restart strategy, maximum restart frequency and child 
%% specifications.
%%--------------------------------------------------------------------
init([]) ->
	process_flag(trap_exit, true),
    timer:start(),
    port_manager:start(),
	{ok, Port} = application:get_env(port),
	B2BUA_Listener = {b2bua_main_listener, {b2bua_main_listener, start_link, [[Port]]}, permanent, 2000, worker, [b2bua_main_listener]},
    {ok, {{one_for_one, 1, 1}, [B2BUA_Listener]}}.

%%====================================================================
%% Internal functions
%%====================================================================
